<?php
/**
 * Created by PhpStorm.
 * User: chl
 * Date: 2017/4/25 0025
 * Time: 15:12
 */
namespace app\admin\controller;
use app\data\Data;
use think\Request;

class System extends Check{
    public function configList(){
        $config_model = new Data('config');
        $config = [];
        $result = $config_model->selectData();
        if(!empty($result)){
            foreach($result as $v){
                $config[$v['cname']] = $v['option'];
            }
        }
        if(Request::instance()->isPost()){
            $post = input('param.');
            foreach( $post as $k=>$v){
                if( $v != $config[$k]){
                    $config_model->setField("cname = '{$k}' ",['option'=>$v]);
                    $config[$k] = $v;
                }
            }
            return $this->formatSuccessResult();
        }
        return view('configList',['result'=>$config]);
    }
}